import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

// 导入模块
import app from './modules/app'
import user from './modules/user'
import settings from './modules/settings'
import theme from './modules/theme'

Vue.use(Vuex)

export default new Vuex.Store({
  modules: {
    app,
    user,
    settings,
    theme
  },
  // 使用vuex-persistedstate插件实现数据持久化
  plugins: [
    createPersistedState({
      key: 'vue2-project-state',
      paths: ['user.token', 'settings.language', 'app.sidebar']
    })
  ]
})
